<?php
/**
 * This class is responsible to represent a view.
 * 
 * 
 * @package    gadgets
 * @subpackage feature
 * @author     Daniel Botelho <botelho.daniel@gmail.com>
 */
class GadgetsView
{
  private $variable;
  private $init;
  
  public function __construct(JSVariable $variable)
  {
    $this->variable = $variable;

    $this->init = false;
  }
  
  public function isInit(){ return $this->init;}
  
  public function init()
  {
    $this->init=true;
    return $this->variable->__toString();
  }
  
  /**
   * return the variable used
   *
   * @return JSVariable variable used
   */
  public function getVariable()
  {
  	return $this->variable;
  }
  
  /**
   * Returns the name of this view.
   *
   * @param boolean $appendable
   * @return string HTML content
   */
  public function getName($appendable=false)
  {
  	return StringUtil::appendableString($this->getVariable()->getName().".getName()",$appendable);
  }
  
  /**
   * Returns true if the gadget is the only visible gadget in this view. On a canvas page or in maximize mode this is most likely true; on a profile page or in dashboard mode, it is most likely false.
   *
   * @param boolean $appendable
   * @return boolean True if the gadget is the only visible gadget; otherwise, false
   */
  public function isOnlyVisibleGadget($appendable=false)
  {
  	return StringUtil::appendableString($this->getVariable()->getName().".isOnlyVisibleGadget()",$appendable);
  }
}